<!--
 * @Description: 该页面功能已经废弃，此页面内容仅做留存以备查询。-- Taoist
-->
<template>
	<!-- is_default 1 默认  is_visit 0 不出诊-->
	<view class="mainPage visit" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="box">
			<view class="box-item" v-for="(item,indexs) in placelist[0]" :key="indexs">
				<view v-if="item.is_visit==1" @click="tanchu1(indexs,item.id,item.tpl_id)">
					<view class="box-top">
						<view class="name">
							<view class="left">
								出诊地名称
							</view>
							<view class="right">
								{{item.address_name}}
								<!-- {{item.id}} -->
							</view>
						</view>
						<view class="location">
							<view class="left">
								出诊地位置
							</view>
							<view class="right">
								{{item.address}}
							</view>
						</view>
						<view class="set">
							<view class="left">
								挂号费设置
							</view>
							<view class="right">
								{{item.register_price}}元
							</view>
						</view>
					</view>
					<view class="box-bottom">
						<view class="title">
							<view class="item">
								<text class="shijian">时间</text>
								<text class="xingqi">星期</text>
							</view>
							<view class="item">
								上午
							</view>
							<view class="item">
								下午
							</view>
						</view>
						<view class="time-list">
							<view class="time-item">
								每周日
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[0].am_sum}}/{{item.duration[0].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[0].pm_sum}}/{{item.duration[0].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周一
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[1].am_sum}}/{{item.duration[1].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[1].pm_sum}}/{{item.duration[1].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周二
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[2].am_sum}}/{{item.duration[2].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[2].pm_sum}}/{{item.duration[2].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周三
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[3].am_sum}}/{{item.duration[3].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[3].pm_sum}}/{{item.duration[3].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周四
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[4].am_sum}}/{{item.duration[4].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[4].pm_sum}}/{{item.duration[4].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周五
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[5].am_sum}}/{{item.duration[5].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[5].pm_sum}}/{{item.duration[5].pm}}</view>
								</view>
							</view>
							<view class="time-item">
								每周六
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[6].am_sum}}/{{item.duration[6].am}}</view>
								</view>
							</view>
							<view class="time-item">
								<view class="wuhao" v-if="false">
									<text>无号</text>
								</view>
								<view class="chuzhen">
									<view>出诊 </view>
									<view>{{item.duration[6].pm_sum}}/{{item.duration[6].pm}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<!--  -->
				<view v-if="item.is_default==0&&item.is_visit==0" @click.stop="tanchu2(indexs,item.id)">
					<view class="box-top">
						<view class="name">
							<view class="left2">
								出诊地名称
							</view>
							<view class="right2">
								{{item.address_name}}
								<!-- {{item.id}} -->
							</view>
						</view>
						<view class="location">
							<view class="left2">
								出诊地位置
							</view>
							<view class="right2">
								{{item.address}}
							</view>
						</view>
					</view>
				</view>
				<!-- 默认地址 -->
				<view v-if="item.is_default==1&&item.is_visit==0" @click.stop="tanchu3(indexs,item.id)">
					<view class="box-top">
						<view class="name">
							<view class="left2">
								出诊地名称
							</view>
							<view class="right2">
								{{item.address_name}}
								<!-- {{item.id}} -->
							</view>
						</view>
						<view class="location">
							<view class="left2">
								出诊地位置
							</view>
							<view class="right2">
								{{item.address}}
							</view>
						</view>
						<view class="location">
							<view class="sets" @click.stop="tomodify2(item.id)">
								设置接诊时间
							</view>
						</view>
					</view>
				</view>
				<!-- 置灰的状态 -->
				<!-- <view class="mengban" v-if="!chuzhenzhuangtai[indexs]"  @click.stop="tanchu2(indexs)">
				</view> -->
			</view>
		</view>
		<view class="null" v-if="!placelist.length">
			<u-empty text="暂无出诊地" mode="address"></u-empty>
		</view>
		<view class="but" @click="addvisit">
			<button>+添加出诊地</button>
		</view>
		<u-popup class="u-popup" v-model="show1" mode="bottom" :safe-area-inset-bottom="true">
			<view class="anniu-box">
				<view class="queren">
					<view class="" @click="closechuzhen">
						暂不出诊
					</view>
					<view class="" @click="tomodify">
						修改
					</view>
					<!-- <view class="" @click="deletes">
						删除
					</view> -->
				</view>
				<view class="quxiao" @click="quxiao">
					取消
				</view>
			</view>
		</u-popup>
		<!-- 点击弹出出诊弹窗 -->
		<u-popup class="u-popup" v-model="show2" mode="bottom" :safe-area-inset-bottom="true">
			<view class="anniu-box">
				<view class="queren">
					<view class="" @click="openchuzhen">
						出诊
					</view>
					<view class="" @click="tomodify">
						修改
					</view>
					<view class="" @click="deletes">
						删除
					</view>
				</view>
				<view class="quxiao" @click="quxiao">
					取消
				</view>
			</view>
		</u-popup>
		<!-- 默认点击弹出出诊弹窗 -->
		<u-popup class="u-popup" v-model="show3" mode="bottom" :safe-area-inset-bottom="true">
			<view class="anniu-box">
				<view class="queren">
					<view class="" @click="openchuzhen">
						出诊
					</view>
					<view class="" @click="tomodify">
						修改
					</view>
					<!-- <view class="" @click="deletes">
					删除
				</view> -->
				</view>
				<view class="quxiao" @click="quxiao">
					取消
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
var that
import publicHead from "@/components/publicHead/publicHead.vue"
export default {
	components: {
		publicHead
	},
	data() {
		return {
			title: "visit2",
			show1: false, //不出诊弹窗
			show2: false, //出诊弹窗
			show3: false, //默认出诊弹窗
			chuzhenzhuangtai: [true, false],
			indexs: 0, //列表索引
			placelist: '',
			czid: 0,
			tpl_id: ''
		}
	},
	onLoad() {
		that = this
	},
	onShow() {
		that.place()
	},
	methods: {
		addvisit() {
			uni.navigateTo({
				url: "./addvisit"
			})
		},
		quxiao() {
			that.show1 = false
			that.show2 = false
			that.show3 = false
		},
		tanchu1(indexs, id, tpl_id) {
			that.show1 = true
			that.indexs = indexs
			that.czid = id
			that.tpl_id = tpl_id
			console.log(indexs, 'id', that.czid, that.tpl_id)
		},
		tanchu2(indexs, id, tpl_id) {
			that.show2 = true
			that.indexs = indexs
			that.czid = id
			that.tpl_id = tpl_id
			console.log(indexs, 'id', that.czid, that.tpl_id)
		},
		tanchu3(indexs, id, tpl_id) {
			that.show3 = true
			that.indexs = indexs
			that.czid = id
			that.tpl_id = tpl_id
			console.log(indexs, 'id', that.czid, that.tpl_id)
		},
		closechuzhen() { //关闭
			that.$postAjax1('Doctorsside_is_visit', {
				visit_id: that.czid,
				visit_isvisit: 0,
			}, function (data) {
				that.chuzhenzhuangtai[that.indexs] = false
				console.log('状态改变')
				that.place()
			})
			that.show1 = false
			that.show2 = false
			that.show3 = false
		},
		openchuzhen() { //打开
			that.$postAjax1('Doctorsside_is_visit', {
				visit_id: that.czid,
				visit_isvisit: 1,
			}, function (data) {
				that.chuzhenzhuangtai[that.indexs] = true
				console.log('状态改变')
				that.place()
			})
			//that.chuzhenzhuangtai[that.indexs]=true
			that.show1 = false
			that.show2 = false
			that.show3 = false
			//这点需要判断时间 是否重复
			// uni.showModal({
			//     title: '提示',
			//     content: '出诊地时间端重复，请修改 该出诊地接诊时间段',
			// 	cancelText:"取消",
			// 	cancelColor:"#333333",
			// 	confirmText:"去修改",
			// 	confirmColor:"#FA6400",
			//     success: function (res) {
			//         if (res.confirm) {
			//             console.log('用户点击确定');
			//         } else if (res.cancel) {
			//             console.log('用户点击取消');
			//         }
			//     }
			// });
		},
		place() {
			that.$postAjax1('Doctorsside_service_settings', {}, function (data) {
				that.placelist = data.data.data.visitaddress
				for (let i = 0; i < that.placelist.length; i++) {
					if (that.placelist[i].is_visit == 0) {
						that.chuzhenzhuangtai[i] = false
					} else if (that.placelist[i].is_visit == 1) {
						that.chuzhenzhuangtai[i] = true
					}
					console.log(that.placelist[i].is_visit)
				}
				console.log('出诊地页面', data)
				for (let key in that.placelist) {
					console.log('循环得到的值', key + ':' + JSON.stringify(that.placelist[key]));
					console.log('循环得到的值', key + ':' + JSON.stringify(that.placelist));
				}
			})
		},
		deletes() {
			that.$postAjax1('Doctorsside_dels_visit', {
				visit_id: that.czid
			}, function (data) {
				console.log('删除成功')
				that.place()
				that.show2 = false
			})
		},
		tomodify() {
			uni.navigateTo({
				url: 'modifyvisit?visit_id=' + that.czid + '&tpl_id=' + that.tpl_id
			})
			that.show1 = false
			that.show2 = false
			that.show3 = false
			console.log('传过去的id', that.czid, that.tpl_id)
		},
		tomodify2(czid) {
			uni.navigateTo({
				url: 'modifyvisit?visit_id=' + czid
			})
			that.show1 = false
			that.show2 = false
			that.show3 = false
			console.log('传过去的id', czid)
		}
	}
}
</script>
<style scoped lang="scss">
.visit {
	padding-bottom: 150rpx;
	min-height: 100vh;
	background-color: #f6f6f6;
	.box {
		.box-item {
			position: relative;
			margin-bottom: 16rpx;
			padding-top: 10px;
			.box-top {
				padding: 0 32rpx;
				background-color: #ffffff;
				border-radius: 20px;
				//margin: 10px;
				//margin-bottom: 16rpx;
				.name,
				.location,
				.set {
					border-bottom: 2rpx solid rgba(0, 0, 0, 0.08);
					display: flex;
					justify-content: space-between;
					align-items: center;
					.sets {
						color: #f29100;
						margin: 15px auto;
					}
					.left {
						font-size: 28rpx;
						font-weight: 400;
						color: #242424;
						line-height: 40px;
					}
					.left2 {
						font-size: 28rpx;
						font-weight: 400;
						color: #d5d5d5;
						line-height: 40px;
					}
					.right {
						font-size: 28rpx;
						font-weight: 500;
						color: #242424;
						line-height: 40rpx;
					}
					.right2 {
						font-size: 28rpx;
						font-weight: 500;
						color: #d5d5d5;
						line-height: 40rpx;
					}
				}
				.set {
					border-bottom: none;
				}
			}
			.box-bottom {
				padding: 22rpx 32rpx 10rpx;
				background-color: #ffffff;
				.title {
					display: flex;
					justify-content: space-between;
					margin-bottom: 12rpx;
					.item {
						width: calc((80% - 24rpx) / 2);
						height: 88rpx;
						background: #ffffff;
						border-radius: 4rpx;
						border: 1rpx solid rgba(0, 0, 0, 0.1);
						font-size: 28rpx;
						font-weight: 500;
						color: #333333;
						line-height: 88rpx;
						text-align: center;
						&:nth-of-type(1) {
							width: 20%;
							position: relative;
							font-size: 26rpx;
							font-weight: 400;
							color: #3b3535;
							overflow: hidden;
							&::before {
								content: "";
								display: block;
								width: 200rpx;
								height: 1rpx;
								position: absolute;
								top: 10rpx;
								left: 0;
								transform: translateY(5rpx) rotate(35deg);
								transform-origin: 15% 0%;
								background-color: rgba(0, 0, 0, 0.1);
							}
							.shijian {
								position: absolute;
								top: 10rpx;
								right: 10rpx;
								font-size: 26rpx;
								font-weight: 400;
								color: #3b3535;
								line-height: 36rpx;
							}
							.xingqi {
								position: absolute;
								bottom: 10rpx;
								left: 10rpx;
								font-size: 26rpx;
								font-weight: 400;
								color: #3b3535;
								line-height: 36rpx;
							}
						}
					}
				}
				.time-list {
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;
					.time-item {
						margin-bottom: 12rpx;
						width: calc((80% - 24rpx) / 2);
						height: 88rpx;
						background: #ffffff;
						border-radius: 4rpx;
						border: 1rpx solid rgba(0, 0, 0, 0.1);
						font-size: 28rpx;
						font-weight: 400;
						color: #768196;
						text-align: center;
						.wuhao {
							line-height: 88rpx;
						}
						.chuzhen {
							view {
								line-height: 44rpx;
							}
						}
						&:nth-of-type(3n + 1) {
							width: 20%;
							font-weight: 500;
							color: #3b3535;
						}
					}
				}
			}
			.mengban {
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				z-index: 99;
				background: rgba(40, 41, 40, 0.2);
			}
		}
	}
	.null {
		padding-top: 500rpx;
		width: 100%;
	}
	.but {
		width: 100%;
		position: fixed;
		z-index: 999;
		bottom: 50rpx;
		button {
			width: 90%;
			background: linear-gradient(219deg, #ff9331 0%, #fe7600 100%);
			border-radius: 8rpx;
			font-weight: 400;
			color: #ffffff;
		}
	}
	.u-popup {
		.anniu-box {
			background-color: transparent;
			padding: 0 16rpx 0;
			// #ifndef MP-WEIXIN
			padding: 0 16rpx 76rpx;
			// #endif
			.queren {
				margin-bottom: 16rpx;
				view {
					width: 100%;
					height: 108rpx;
					background: #efefef;
					text-align: center;
					font-size: 40rpx;
					font-weight: 400;
					color: #2f78f3;
					line-height: 108rpx;
					border-bottom: 2rpx solid rgba(0, 0, 0, 0.08);
					&:nth-of-type(1) {
						border-radius: 26rpx 26rpx 0 0;
					}
					&:nth-of-type(3) {
						border-radius: 0 0 26rpx 26rpx;
						color: #ff0000;
						border: none;
					}
				}
			}
			.quxiao {
				width: 100%;
				height: 116rpx;
				background: #efefef;
				border-radius: 26rpx;
				text-align: center;
				font-size: 40rpx;
				font-weight: 400;
				line-height: 116rpx;
				color: #2f78f3;
			}
		}
	}
}
</style>
